package cn.hdu.liang.ch03;

interface EventListener {
    void onEvent(Event e);
}

interface Event {
}

interface EventSource {
    void registerListener(EventListener e);
}

/**
 * 隐式地使this引用逸出
 */
public class ThisEscape {
    public ThisEscape(EventSource source) {
        source.registerListener(new EventListener() {
            public void onEvent(Event e) {
                doSomething(e);
            }
        });
    }

    void doSomething(Event e) {
    }

}

